#include <54func.h>
int main(int argc,char *argv[])
{
    // ./1_homework_filecompare file1 file2  -->  比较两个文件夹内容是否一致！！！
    ARGS_CHECK(argc,3);
    int fd1 = open(argv[1],O_RDONLY);
    int fd2 = open(argv[2],O_RDONLY);
    
    char buf1[1024]={0};
    char buf2[1024]={0};
    while(1){
        //读文件之前先清空
        memset(buf1,0,sizeof(buf1));
        memset(buf2,0,sizeof(buf2));
        //读取文件即可
        ssize_t sret1 = read(fd1,buf1,sizeof(buf1));
        ssize_t sret2 = read(fd2,buf2,sizeof(buf2));

        //比较文件一致
        if(sret1 != sret2){        //长度不一致
            printf("Not same!\n");
            break;
        }else if(memcmp(buf1,buf2,sret1) != 0)  //s1和s2内容不同的时候，继续读
        {
            printf("Not same!\n");
            break;
        }else if(sret1 == 0){
            printf("same!\n");
            break;
        }
    }

    return 0;
}
